Skip to main content

安装MySQL

查看cpu构架:

lscpu

mysql可能用于hive组件元数据库,本集群任意节点安装即可。

1. 安装包下载

wget https://redoop-public-1.oss-cn-beijing.aliyuncs.com/redoop/9.1/arm64/share/mysql/mysql-5.7.27-aarch64.tar.gz
# 解压缩安装包
tar -xvf mysql-5.7.27-aarch64.tar.gz

2.安装依赖项

yum install -y libaio*

3.配置MySQL

# 移动文件到/usr/local/mysql
mv /usr/local/mysql-5.7.27-aarch64 /usr/local/mysql

# 创建logs目录
mkdir -p /usr/local/mysql/logs

# 建立软连接
ln -sf /usr/local/mysql/my.cnf /etc/my.cnf

# 强制覆盖拷贝
cp -rf /usr/local/mysql/extra/lib* /usr/lib64/
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old
ln -s /usr/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6

# 创建mysql组
groupadd mysql
# 创建mysql用户添加到mysql组
useradd -g mysql mysql
# 将/usr/loca/mysql目录包含所有的子目录和文件,所有者改变为root,所属组改变为mysql
chown -R mysql:mysql /usr/local/mysql

设置开机启动

cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
chmod +x /etc/init.d/mysqld
systemctl enable mysqld

添加环境变量

vim /etc/profile/mysql.sh
# 添加下面两行代码
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile

初始化mysql

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

开启mysql

systemctl start mysqld

查看状态

systemctl status mysqld

4.配置账号

编辑/usr/local/mysql/my.cnf

# 在 [mysqld] 添加这一行,跳过密码验证
skip-grant-tables
# 创建软连接
ln -s /usr/local/mysql/bin/mysql /usr/bin
# 登录mysql
mysql -uroot

更改MySQL密码策略

set global validate_password_length=4; 
set global validate_password_policy=0;

设置简单好记的密码

set password=password("123456");

进入MySQL库

use mysql;

查询user表

select user, host from user;

修改user表,把Host表内容修改为%

update user set host="%" where user="root";

注意,修改最大连接数

set GLOBAL max_connections=1024; 
show variables like '%max_connections%';
show status like 'Threads%';

刷新

flush privileges;

退出

quit;

编辑/usr/local/mysql/my.cnf

# 在 [mysqld] 下面删除以下行
skip-grant-tables